#include <string>
#include <vector>
#include "Arca.h"
Ark::Ark()
{
    nrAnimale=0;
    time=0;
}

void Ark::addAnimal(Animal *a)
{
    if (this->nrAnimale<MAX)
    {
        this->animale[nrAnimale++]=a;
    }
    else cout<<"Arca e plina!";
}

template<class T> bool isGestant(T p)
{
    if (p->gender==female)
    {
        if (p->gestanta>0)
        {
            return true;
        }
    }
    else return false;
}
void Ark::passTime(int x)
{
    time=time+x;
    int i=0;
    while (i<=nrAnimale)
    {
        if (animale[i]->getVarsta()+time>animale[i]->getLimitaVarsta())
        {
            for (int j=i;j<nrAnimale;j++)
                animale[j]=animale[j+1];
            nrAnimale--;
        }
        else 
        { 
            animale[i]->setVarsta(animale[i]->getVarsta());
            if ( isGestant(animale[i]))
            {
                giveBirth(animale[i]);
            }
        }
        
    }
    
}

void Ark::giveBirth(Animal *c)
{
    Animal* x=new Animal;
    this->addAnimal(x);
}
